#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a[N];
void solve() {
  cin >> n >> m;
  rep(i, 1, m) cin >> a[i];
  sort(a + 1, a + m + 1);
  ll sum = 0;
  rep(l, 1, n - 1) {
    int r = n - l;
    int mn = min(l, r);
    int mx = max(l, r);
    int cnt1 = a + m + 1 - lower_bound(a + 1, a + m + 1, mn);
    int cnt2 = a + m + 1 - lower_bound(a + 1, a + m + 1, mx);
    sum += 1ll * cnt2 * (cnt1 - 1);
  }
  cout << sum << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}